﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhittleList.Bll;

namespace WhittleList.Tests.Mocks
{
    public class FakeUserProjectRole : Moq.Mock<UserProjectRole>
    {
        public FakeUserProjectRole(int id)
        {
            this.Setup(x => x.Id).Returns(id);
            this.SetupProperty(x => x.Approved, false);
        }

        public static List<FakeUserProjectRole> GetList(int number)
        {
            var tmp = new List<FakeUserProjectRole>();
            while (tmp.Count < number)
            {
                tmp.Add(new FakeUserProjectRole(tmp.Count + 1));
            }
            return tmp;
        }

        public void SetUser(FakeUser user)
        {
            this.Setup(x => x.User).Returns(user.Object);
            this.Setup(x => x.UserId).Returns(user.Object.Id);
        }

        public void SetProject(FakeProject project)
        {
            this.Setup(x => x.Project).Returns(project.Object);
            this.Setup(x => x.ProjectId).Returns(project.Object.Id);
        }
    }

    /*public static class FakeUserProjectRoleHelpers
    {
        public static IQueryable<UserProjectRole> Convert(this List<FakeUserProjectRole> items)
        {
            return items.AsQueryable().Convert();
        }

        public static IQueryable<UserProjectRole> Convert(this IQueryable<FakeUserProjectRole> items)
        {
            return items != null ? items.Select(x => x.Object) : null;
        }
    }*/
}
